package com.aw.baselib.widgets.font

import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Canvas
import android.util.AttributeSet
import android.widget.TextView
import com.aw.baselib.R
import com.aw.baselib.base.AwBaseApplication
import com.aw.baselib.util.AwToastUtil

/**
 * @author : hzw
 * https://blog.csdn.net/yuanxw44/article/details/80019501
 */
@SuppressLint("AppCompatCustomView")
abstract class AwTvRegularBase(private val mContext: Context, attrs: AttributeSet?) : TextView(
    mContext, attrs
) {
    protected abstract fun setViewBg()

    init {
        setHintTextColor(resources.getColor(R.color.color_app_gray_light))
    }

    override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
        super.onLayout(changed, left, top, right, bottom)
    }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
    }

    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec)
    }

    fun showChooseHint() {
        showCustomHint("Please choose.")
    }

    fun showCustomHint(msg: String?) {
        setViewBg()
        AwToastUtil.showShort(AwBaseApplication.instance, msg)
    }
}